import React, { useEffect, useMemo, useState } from "react";
import "./index.css";
import { Input, Button } from "antd-mobile";
function Index() {
  const user_id = 2;
  const server_id = 4553;
  const ws = useMemo(() => {
    return new WebSocket(
      `ws:113.44.139.133:8003/koa/ws?user_id=${user_id}&server_id=${server_id}`
    );
  }, []);

  const [chatlist, setchatlist] = useState([]);
  const [value, setValue] = useState("");

  useEffect(()=>{
    ws.onopen=()=>{
      console.log("连接成功")
      ws.send(JSON.stringify({type:"getChatList"}))
    }

    ws.onmessage=(msg)=>{
      const {type,message,data}=JSON.parse(msg(data))
      if(type==="getChatList")
    }
  },[])
  return (
    <div className="chat">
      <div className="main"></div>
      <div className="footer">
        <Input
          placeholder="请输入内容"
          value={value}
          onChange={(val) => {
            setValue(val);
          }}
        />
        <Button size="small" color="primary">
          发送
        </Button>
      </div>
    </div>
  );
}

export default Index;
